package com.sskj.mine.ui.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.sskj.common.base.App;
import com.sskj.common.util.ClickUtil;
import com.sskj.common.util.SPUtil;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.RConfig;
import com.sskj.lib.SPConfig;
import com.sskj.lib.base.BaseActivity;
import com.sskj.mine.R;
import com.sskj.mine.R2;
import com.sskj.mine.presenter.MineVerificationJuniorPresenter;

import butterknife.BindView;
import butterknife.ButterKnife;

@Route(path = RConfig.MINE_VERFICATION_JUNIOR)//初级认证
public class MineVerficationJuniorActivity extends BaseActivity<MineVerificationJuniorPresenter> {

    @BindView(R2.id.etName)
    EditText etName;
    @BindView(R2.id.etIDCard)
    EditText etIDCard;
    @BindView(R2.id.btSubmit)
    Button btSubmit;

    @Override
    protected int getLayoutResId() {
        return R.layout.mine_activity_verfication_junior;
    }

    @Override
    public MineVerificationJuniorPresenter getPresenter() {
        return new MineVerificationJuniorPresenter();
    }

    @Override
    public boolean getImmersion() {
        return false;
    }

    @Override
    protected void initView() {
        super.initView();
        ClickUtil.click(btSubmit, () -> {
            String identNum = etIDCard.getText().toString().trim();
            String realName = etName.getText().toString().trim();

            if (!realName.matches("^[A-Za-z\\u4e00-\\u9fa5]+$")) {
                ToastUtil.showShort(App.INSTANCE.getString(R.string.mineCertificationActivity5));
                return;
            }
            if (TextUtils.isEmpty(realName)) {
                ToastUtil.showShort(App.INSTANCE.getString(R.string.mineCertificationActivity6));
                return;
            }
            if (TextUtils.isEmpty(identNum)) {
                ToastUtil.showShort(App.INSTANCE.getString(R.string.mineCertificationActivity7));
                return;
            }
            if (identNum.length() != 18) {
                ToastUtil.showShort(App.INSTANCE.getString(R.string.mineCertificationActivity8));
                return;
            }
            mPresenter.verificationJunior(SPUtil.get(SPConfig.ID, ""), realName, identNum);
        });
    }

    @Override
    protected void initData() {

    }
}
